var app = getApp();
var API_URL = 'https://wxapp.campushire.online/function/addFeedback';


Page({
  data:{
    
  },
  onLoad: function() {
    
  },
  bindTextAreaBlur: function(e) {
    console.log(e.detail.value);
    var that = this;
    that.setData({
      textDetails: e.detail.value
    });
  },
  confirmBtn:function(){
    var that = this;
    wx.showModal({
      title: '确定提交反馈意见吗？',
      content: '非常感谢大家的宝贵意见哦！',
      success: function(res) {
        if (res.confirm) {
          console.log('确认提交发布');
          if(that.data.textDetails){
            console.log("填入反馈意见");
            wx.request({
              url: API_URL,
              header:{
                'Content-Type': 'application/x-www-form-urlencoded',
                "sessionid": app.globalData.sessionid
              },
              method: "POST",
              data: {
                content:that.data.textDetails
              },
              success:function(res){
                console.log(res.data);
              }
            });
            wx.switchTab({
              url: '/pages/user/user'
            });
            wx.showToast({
              title: '感谢亲哦！',
              icon: 'success',
              duration:3000
            });
          } else {
            console.log("还没填写");
            wx.showToast({
              title: '亲，你还没填写反馈意见哦！',
              icon: 'none',
              duration:2000
            })
          }
          
        } else if (res.cancel) {
          console.log('用户点击取消')
          wx.showToast({
            title:"亲继续编辑吧！",
            icon:"success",
            duration:3000
          });
        }
      }
    })
  }
  

})